<template>
  <div class="inOutSaveDaily">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">进出存合并</span>
      </div>
      <s-table
        :table="table"
        @http="tableWatch">
        <el-form-item label="选择时间" prop="sj">
          <el-date-picker
            v-model="autoVue_table_sj"
            type="month"
            placeholder="选择日期范围">
          </el-date-picker>
        </el-form-item>
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
      </s-table>
    </el-card>
  </div>
</template>

<script>
  import {AutoVue} from '~/plugins/Tools';
  export default AutoVue({
    name: 'journaling_inOutSaveDaily-FEcarWms',
    head: {
      'title': '进出存合并管理',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 进出存合并 查看进出存合并信息' },
      ],
    },
    store: ['USER'],
    data: {
      table: {
        column: [
          { label: '质检出库',
            prop: 'zjck',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '质检入库',
            prop: 'zjrk',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '收货数量',
            prop: 'shsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '上月结存',
            prop: 'syjc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '本月结存',
            prop: 'byjc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '不合格品入库',
            prop: 'hpslrk',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '不合格品出库',
            prop: 'hpslck',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '出库数量',
            prop: 'cksl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '时间',
            prop: 'sj',
            minWidth: '90px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'Month',
            search: true },
        ],
        url: '/reports/outStock',
        key: 'id',
        tableColumn: 7,
      },
    },
    methods: {
      tableExport (row) {
        let tableRef = 'table';
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          this[tableRef].multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将导出进出存和并报表数据。', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: '/reports/getoutStock',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
    },
    transition: 'slide-fade',
    mounted: function () {
      this.tableWatch('table');
    },
  });
</script>
<style scoped lang="scss">
  .box-card {
    margin: 20px;
  }

  .createTimeSpan {
    display: block;
    margin-top: 34px;
  }

  @media screen and (max-width: 800px) {
    .createTimeSpan {
      margin-top: 0;
    }
    .box-card {
      margin: 0;
    }
  }

  .el-select {
    width: 100%;
  }
</style>

<style lang="scss">
</style>
